extends Node2D

@export var gold_enemy_tscn: PackedScene
@onready var tele_portation_point: Node2D = %TelePortationPoint
@onready var start_point: Node2D = %StartPoint
@onready var end_point: Node2D = %EndPoint

var gold_enemy: GoldEnemy
func _ready() -> void:
	EventBus.subscribe("to_des", on_to_des)

func on_to_des(_name):
	if _name == "attack_gold":
		RaffleManager.attack_gold_count -= 1
		if gold_enemy:
			gold_enemy.queue_free()
		gold_enemy = gold_enemy_tscn.instantiate()
		self.add_child(gold_enemy)
		gold_enemy.set_start_point(start_point)
		gold_enemy.set_end_point(end_point)
		Utils.player.global_position = tele_portation_point.global_position

